package com.qfedu.cardlikeboot.service.impl;

import com.qfedu.cardlikeboot.domain.User;
import com.qfedu.cardlikeboot.mapper.UserMapper;
import com.qfedu.cardlikeboot.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;

/**
 * @auther asus
 * @date 2022/5/18 20:42
 */
@Service
public class UserServiceImpl implements UserService {

    @Resource
    UserMapper userMapper;

    @Override
    public User login(String username, String password) {
        List<User> users = userMapper.selectByName(username);
        if (Objects.nonNull(users)) {
            for (User user : users) {
                if (Objects.equals(password,user.getPassword())){
                    return user;
                }
            }
        }
        return null;
    }
}
